var PreviewComponent = require('./preview.vue');
var $vm

module.exports = {
	install:function(Vue) {
	    var Preview = Vue.extend(PreviewComponent)
	    if (!$vm) {
	      $vm = new Preview({el: document.createElement('div')})
	      document.body.appendChild($vm.$el)
	    }
	    const preview = {
	      open:function(index, list, params,e) {
	        $vm.open(index, list, params,e)
	      },
	      close:function() {
	        $vm.close()
	      }
	    }
	    Vue.$preview = preview
	    Vue.mixin({
	      created: function () {
	        this.$preview = Vue.$preview
	      }
	    })
	  }	
}

